GBML manual / Sets

set_contains

True if value is currently a member of target, false otherwise. Exactly the same as set_has - this is the name that matches list_contains, stack_contains and queue_contains.

Syntax

set_contains(target, value) -> bool

Arguments

NameType
targetset
valueelement

Returns

bool

Description

true if value is currently a member of target, a set, false otherwise. Checking is fast no matter how many values target already holds.

This is exactly the same as set_has - the same question, the same answer, the same speed. It has a second name so that the question is spelled the same way on every container: list_contains for a list, stack_contains for a stack, queue_contains for a queue and set_contains for a set. Use whichever you like; a game that already says set_has keeps working.

What happens in the awkward cases

You do thisWhat happens
ask about a value that was never addedfalse
ask about a value that was added and then removedfalse
ask an empty setfalse
give it a listrefused when checked. A list has its own, list_contains

Example

/// @type {set<int>}
var visited = [5];
var has5 = set_contains(visited, 5); // true
var has6 = set_contains(visited, 6); // false

On the GBA

Just the hash set's contains() - O(1) average, the identical code set_has writes.

See also: set_hasset_addset_removeset_lengthlist_containsSetsData containers